/*----------------------------------------------------------------
// Copyright (C) 2011  博览财经资讯服务有限公司
// 版权所有
// 文件名：DBCommOleDb
// 文件功能描述：ACCESS数据库的数据接口
// 
// 创建标识:王家新
// 
// 修改标识：
// 修改描述：
//         
// 修改标识：
// 修改描述：
//----------------------------------------------------------------*/

using System;
using System.Collections.Generic;
using System.Text;
using System.Data.OleDb;
using System.Data.Common;
using System.Data;

namespace Aij1.Utils
{
    /// <summary>
    /// ACCESS数据库的数据接口实现
    /// </summary>
    public class DBCommOleDb : IDBComm
    {
        public DBHelper Helper { get; set; }
        /// <summary>
        /// 参照接口定义
        /// </summary>
        /// <param name="connectionString"></param>
        /// <returns></returns>
        public DbConnection CreateConnection()
        {
            return new OleDbConnection(Helper.ConnStr);
        }

        /// <summary>
        /// 参照接口定义
        /// </summary>
        /// <param name="connectionString"></param>
        /// <returns></returns>
        public DbCommand CreateCommand(string sql)
        {
            return new OleDbCommand(sql, (OleDbConnection)CreateConnection());
        }

        /// <summary>
        /// 参照接口定义
        /// </summary>
        /// <param name="connectionString"></param>
        /// <returns></returns>
        public DbDataAdapter CreateDataAdapter(DbCommand command)
        {
            return new OleDbDataAdapter((OleDbCommand)command);
        }

        /// <summary>
        /// 参照接口定义
        /// </summary>
        /// <param name="connectionString"></param>
        /// <returns></returns>
        public DbParameter CreateParameter(string parameterName, object value)
        {
            OleDbParameter param = new OleDbParameter(parameterName, CommOp.TestNull(value));
            return param;
        }

        /// <summary>
        /// 生成二进制参数
        /// </summary>
        /// <param name="parameterName"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public DbParameter CreateImageParameter(string parameterName, byte[] value)
        {
            OleDbParameter param = new OleDbParameter(parameterName, OleDbType.Binary);
            param.Value = CommOp.TestNull(value);
            return param;
        }

        public double GetDBSize()
        {
            throw new NotImplementedException();
        }

        public void ShrinkDB()
        {
            throw new NotImplementedException();
        }
    }
}
